
package tool.disuse;

import java.sql.*;

public class DbUtils {
	static String DBUrl = "jdbc:mysql://192.168.1.199:3306/mysql3235";
	static String user="hfjxt";
	static String psw="qwertyhnm800";
	
    static {
        try {
            Class.forName("com.mysql.jdbc.Driver");
        } catch(Exception ex) {
            System.err.println(ex);
        }
    }

    public static Connection getConn() throws Exception {
        return DriverManager.getConnection(DBUrl,user,psw);
    }

    public static void close(ResultSet rs, Statement state, Connection conn) {
        if (rs != null) {
            try {
                rs.close();
            } catch(SQLException ex) {
                ex.printStackTrace();
            }
            rs = null;
        }
        if (state != null) {
            try {
                state.close();
            } catch(SQLException ex) {
                ex.printStackTrace();
            }
            state = null;
        }
        if (conn != null) {
            try {
                conn.close();
            } catch (Exception ex) {
                ex.printStackTrace();
            }
            conn = null;
        }
    }
}
